#include <string>
#include <iostream>
#include <algorithm>

std::string AddBigNumber(std::string a, std::string b) {
    //准备结果
    std::string result;


    //a是大数，b是小数
    if (a.size() < b.size()) {
        std::swap(a, b);
    }

    int aLen = a.size();
	int bLen = b.size();
    //b补0对齐
    for (int i = 0; i < aLen - bLen; i++) {
        b.insert(b.begin(), '0');
    }

    //进位
    int carry = 0;

    for (int i = aLen - 1; i >= 0; i--) {
        //转成数字，相加，加上进位
        int num = (a[i] - '0') + (b[i] - '0') + carry;
        //计算进位
        carry = num / 10;
        //计算当前位
        num = num % 10;
        //转成字符拼接到结果
        result = (char)(num + '0') + result;
        printf("result: %p\n", result.c_str());
    }

    //最后还有进位，需要补上
    if (carry > 0) {
        result = (char)(carry + '0') + result;
    }

    return result;
}



int main(){

    std::string a = "100000000000000000000000";
    std::string b = "20000000000000000000000000000";


    std::string result = AddBigNumber(a, b);
    std::cout << result << "\n";

    return 0;
}